/*
 *
自行编写一个类，通过typeid和typeinfo动态输出该类对象的类型
animal1的实际类型是3Cat
animal2的实际类型是3Dog
animal1是一只猫
animal2是一条狗

注：3Dog 是编译器修饰后的名称
 *
 */
#include<iostream>
#include<typeinfo>
using namespace std;

class Animal{
	public:
		virtual ~Animal(){}
};

class Cat: public Animal{};
class Dog: public Animal{};

int main(){
	Animal* animal1 = new Cat();
	Animal* animal2 = new Dog();

	cout << "animal1的实际类型是" << typeid(*animal1).name() << endl;
	cout << "animal2的实际类型是" << typeid(*animal2).name() << endl;

	if(typeid(*animal1) == typeid(Cat)){
		cout << "animal1是一只猫" << endl;
	}
	
	if(typeid(*animal2) == typeid(Dog)){
		cout << "animal2是一条狗" << endl;
	}

	delete animal1;
	delete animal2;

	return 0;
}
